<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改用户')" />
	<th:block th:include="include :: select2-css" />
</head>
<body>
    <div class="main-content">
        <form class="form-horizontal" id="form-user-edit" th:object="${people}">
            <input name="id"  type="hidden"  th:field="*{id}" />
            <h4 class="form-header h4">基本信息</h4>
            <div class="row">
            	<div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span style="color: red; ">*</span>姓名：</label>
                        <div class="col-sm-10">
                            <input name="name" placeholder="请输入姓名" class="form-control" type="text" maxlength="30" th:field="*{name}" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span style="color: red; ">*</span>描述：</label>
                        <div class="col-sm-10">
                            <textarea name="description" maxlength="500" class="form-control" rows="3">[[*{description}]]</textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>权重：</label>
                        <div class="col-sm-8">
                            <input name="symbol" placeholder="请输入权重" class="form-control" type="text" value="50" th:field="*{symbol}" required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>颜色：</label>
                        <div class="col-sm-8">
                            <input name="color" placeholder="请输入颜色" class="form-control" type="text" value="black" th:field="*{color}" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">关系：</label>
                        <div class="col-xs-10">
                            <label th:each="p:${peoples}" class="check-box">
                                <input name="releation" type="checkbox" th:value="${p.id}" th:text="${p.name}">
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4">其他信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">备注：</label>
                        <div class="col-xs-10">
                            <textarea name="remark" maxlength="500" class="form-control" rows="3">[[*{remark}]]</textarea>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
        var prefix = ctx + "people";
        
        $("#form-user-edit").validate({
        	onkeyup: false,
        	rules:{
        	},
        	messages: {
            },
            focusCleanup: true
        });
        
        function submitHandler() {
	        if ($.validate.form()) {
	        	var data = $("#form-user-edit").serializeArray();
	        	var releationIds = $.form.selectCheckeds("releation");
	        	data.push({"name": "releationIds", "value": releationIds});
	        	$.operate.saveTab(prefix + "/edit", data);
	        }
	    }
    </script>
</body>
</html>